import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

import 'package:top_foundation/utils/util.dart';

import 'dialog/index.dart';

Future<T?> showAlert<T>({
  final String? title,
  final String? msg,
  final Widget? content,
  final String? cancelText = '取消',
  final String? sureText = '确定',
  final Color? cancelColor,
  final Color? sureColor,
  final BoolResultCallback? conditionDismiss,
}) {
  return showWindow(
    m: DialogModel(
      title: title,
      msg: msg,
      content: content,
      cancelColor: cancelColor,
      cancelText: cancelText,
      sureColor: sureColor,
      sureText: sureText,
      margin: EdgeInsets.symmetric(horizontal: 0.2.sw),
    ),
  );
}

Future<T?> showWindow<T>({
  required DialogModel m,
}) async {
  return Get.to(
    () => const DialogPage(),
    arguments: m,
    binding: DialogBinding(),
    transition: Transition.fadeIn,
    fullscreenDialog: true,
    popGesture: false,
    opaque: false,
  );
}
